package com.ww.springboot.boot.job;

import java.util.Date;

import cn.hutool.core.date.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author ZH500
 */
@EnableScheduling
@Component
@Async
@Slf4j
public class ScheduledService {
	
	public ScheduledService() {
		
	}

	/**
	 * 每个星期五的18点整触发
	 */
	@Scheduled(cron = "0 0 18 ? * FRI")
	public void sendWeekly(){
		log.info("cron测试开始");
		System.out.println(new Date());
		log.info("cron测试结束");
	}

	/**
	 * 每天的整点触发
	 */
	@Scheduled(cron = "0 0 * * * *")
	public void makeData(){
		System.out.println("整点播报"+ DateUtil.formatDate(new Date()));
	}
}
